package com.snb.play.dwebtoon.data;

import java.util.ArrayList;
import java.util.Iterator;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class DTO_EpisodeToon extends JSonDataObjectBase {

	/**
	 * 
	 */
	private static final long serialVersionUID = 135930235996L;
	public String isReadFinish;
	public String id;
	public String pid;
	public String title;
//	public String episodeTitle;
	public String viewType;
//	public String artist;
//	public String size;
//	public String encryptUseYn;
	public ArrayList<DTO_EpisodeImage> images;

	public String getIsReadFinish() {
		return isReadFinish;
	}

	public String getId() {
		return id;
	}

	public String getPid() {
		return pid;
	}

	public String getTitle() {
		return title;
	}

	public String getViewType() {
		return viewType;
	}

	public ArrayList<DTO_EpisodeImage> getImages() {
		return images;
	}

	public void setIsReadFinish(String isReadFinish) {
		this.isReadFinish = isReadFinish;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setViewType(String viewType) {
		this.viewType = viewType;
	}

	public void setImages(ArrayList<DTO_EpisodeImage> images) {
		this.images = images;
	}

	public DTO_EpisodeToon() {
		super();
	}

	public DTO_EpisodeToon(JSONObject aJsonObject) {
		@SuppressWarnings("unchecked")
		Iterator<Object> iterator = aJsonObject.keys();

		while (iterator.hasNext()) {
			Object obj = iterator.next();
			if (obj.toString().equalsIgnoreCase("images")) {
				this.images = new ArrayList<DTO_EpisodeImage>();
				DTO_EpisodeImage lEpisodeImage = null;
				try {

					JSONArray lImages = aJsonObject.getJSONArray("images");

					for (int i = 0; i < lImages.length(); i++) {
						lEpisodeImage = new DTO_EpisodeImage(lImages.getJSONObject(i));
						this.images.add(lEpisodeImage);
					}

				} catch (JSONException e) {
					if (isDebug)
						e.printStackTrace();
				}

			} else {
				setMemberFiled(this, aJsonObject, obj.toString());
			}
		}

		printMembers();
	}

}
